<?php
/**
 * Created by PhpStorm.
 * User: 戎大富
 * Date: 2020/2/20
 * Time: 8:36
 */
namespace app\admin\controller;


use think\Db;
use think\Request;
class About extends Base
{
    /**
     * 奖励（老麻）
     * @return mixed|\think\response\Json
     */
    public function other(){
        if(Request::instance()->isPost()){
            extract(input());
            $insert = [
                'default' => $default,
                'must' => $must,
                'nomust' => $nomust ,
                'alldays' => $alldays ,
                'miles' => $miles ,
                'month_3' => $month_3,
                'month_6' => $month_6,
                'month_9' => $month_9,
                'time' => date('Y-m-d H:i:s')
            ];
            $res = Db::table('up_shop_config')->where('id', 1)->update($insert);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $data = Db::table('up_shop_config')->where('id', 1)->find();
        $this->assign('data', $data);
        return $this->fetch('about/phone');
    }
    
    /**
     * 联系我们
     * @return mixed|\think\response\Json
     */
    public function withUs(){
        if(Request::instance()->isPost()){
            $service_phone = input('service_phone');
            $black_image = input('black_image');
            
            $update = [
                'service_phone' => $service_phone,
                'black_image' => $black_image,
                'updatetime' => date('Y-m-d H:i:s')
            ];
            $res = Db::table('up_about')->where('id', 3)->update($update);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $data = Db::table('up_about')->where('id', 3)->field('service_phone, black_image')->find();
        $this->assign('data', $data);
        return $this->fetch('about/withus');
    }
    
    /**
     * 验证码模式
     * @return mixed|\think\response\Json
     */
    public function changeMode(){
        if(Request::instance()->isPost()){
            $yzm_mode = input('yzm_mode');
            $res = Db::table('up_about')->where('id', 2)->update(['content' => $yzm_mode, 'updatetime' => date('Y-m-d H:i:s')]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $mode = Db::table('up_about')->where('id', 2)->value('content');
        return $this->fetch('about/changemode', ['mode' => $mode]);
    }
    
    /**
     * 功能介绍
     * @return mixed|\think\response\Json
     */
    public function gong(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('id', 4)->update(['content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('id', 4)->find();
        $this->assign('content', $about_content);
        return $this->fetch('about/gong');
    }
    
    /**
     * 法律声明
     * @return mixed|\think\response\Json
     */
    public function falv(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('id', 5)->update(['content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('id', 5)->find();
        $this->assign('content', $about_content);
        return $this->fetch('about/falv');
    }
    
    /**
     * 隐私政策
     * @return mixed|\think\response\Json
     */
    public function ys(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('id', 9)->update(['content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('id', 9)->find();
        $this->assign('content', $about_content);
        return $this->fetch('about/ys');
    }
    
    /**
     * 快递公司
     * @return mixed|\think\response\Json
     */
    public function kuaiD(){
        if(Request::instance()->isPost()){
            $content = input('content');
            
            $update = [
                'content' => $content,
                'updatetime' => date('Y-m-d H:i:s')
            ];
            $res = Db::table('up_about')->where('id', 7)->update($update);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('id', 7)->value('content');
        $this->assign('about_content', $about_content);
        return $this->fetch('about/kuaid');
    }
    
    /**
     * 平台协议
     * @return mixed|\think\response\Json
     */
    public function pingTai(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('id', 6)->update(['content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('id', 6)->find();
        $this->assign('content', $about_content);
        return $this->fetch('about/pingtai');
    }
    
    /**
     * 提现规则
     * @return mixed|\think\response\Json
     */
    public function txRule(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('id', 8)->update(['content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('id', 8)->find();
        $this->assign('content', $about_content);
        return $this->fetch('about/txrule');
    }

    /**
     * 私人订制承诺图
     * @return mixed|\think\response\Json
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     */
    public function privateCnImg(){
        if(Request::instance()->isPost()){
            $content = input('content');

            $update = [
                'content' => $content,
                'updatetime' => date('Y-m-d H:i:s')
            ];
            $res = Db::table('up_about')->where('id', 12)->update($update);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $data = Db::table('up_about')->where('id', 12)->field('content')->find();
        $this->assign('data', $data);
        return $this->fetch('');
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    //********************************   以下备用
    
    
    /**
     * 隐私协议
     * @return mixed|\think\response\Json
     */
    public function yinsi(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('id', 2)->update(['content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('id', 2)->find();
        $this->assign('content', $about_content);
        return $this->fetch('about/yinsi');
    }
    /**
     * 关于我们
     * @return mixed|\think\response\Json
     */
    public function about(){
        if(Request::instance()->isPost()){
            $about_content = input('about_content');
            $res = Db::table('up_about')->where('id', 3)->update(['content' => $about_content]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $about_content = Db::table('up_about')->where('id', 3)->find();
        $this->assign('content', $about_content);
        return $this->fetch('about/about');
    }
    
    
    
    

    

}